package com.cn.controller;

import com.cn.api.ApiResult;
import com.cn.pojo.shop.ShopSpec;
import com.cn.service.ShopSpecService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/spec")
public class SpecController {

    @Autowired
    private ShopSpecService shopSpecService;


    /**
     * 查询规格数据
     * @return
     */
    @GetMapping("/querySpec")
    public ApiResult querySpec(){
        return shopSpecService.querySpec();
    }


    /**
     *
     * @param shopSpec 规格信息
     * @param id 商品信息
     * @return
     */
    @PutMapping("/updateSpec")
    public ApiResult updateSpec(@RequestBody ShopSpec shopSpec,Integer id){
        return shopSpecService.updateSpec(shopSpec,id);
    }


    /**
     * 添加
     * @param shopSpec 规格数据
     * @param id
     * @return
     */
    @PostMapping("/addSpec")
    public ApiResult addSpec(@RequestBody ShopSpec shopSpec,Integer id){
        return shopSpecService.addSpec(shopSpec,id);
    }

    /**
     * 删除规格
     * @param id
     * @return
     */
    @DeleteMapping("/deleteSpec/{id}")
    public ApiResult deleteSpec(@PathVariable("id") Integer id){
        return shopSpecService.deleteSpec(id);
    }

}
